package com.yanti.service.impl;

import com.yanti.domain.ResponseResult;
import com.yanti.domain.vo.UploadFileRspVO;
import com.yanti.service.FileService;
import com.yanti.strategy.FileStrategy;
import jakarta.annotation.Resource;
import lombok.extern.slf4j.Slf4j;
import org.springframework.stereotype.Service;
import org.springframework.web.multipart.MultipartFile;


@Service
@Slf4j
public class FileServiceImpl implements FileService {

    @Resource
    private FileStrategy fileStrategy;

    private static final String BUCKET_NAME = "yanti";

    @Override
    public ResponseResult<?> uploadFile(MultipartFile file){
        // 上传文件到
        String url = fileStrategy.uploadFile(file, BUCKET_NAME);
        return ResponseResult.okResult(UploadFileRspVO.builder().url(url).build());
    }
}